<?php

namespace app\common\tool;


use Yansongda\Pay\Pay;
use Yansongda\Pay\Log;

class PayTool
{
    /*
     * $config = [
            'app_id' => '2018053160276379',
            'ali_public_key' => 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArkvOKDcsDkvMTpYuuA3QnY6pn3g8Uej9Lp4JRw64EjVi87nTE2YZCHRpQBSkC99yCRwqx7FO9GcKP2tT4GrdK0mWOiV5z1y2s6fj4DRreCsGrwH1640jLjEiJL4+byxKeqWE0m4K9Mpa3Jx/IGxDhAhAMILnuWPrRBjhiORygalHvPHO2q1pKAXrewrMRS7zxlbjUp3KHIaL8QVBQa0GbIc/chBGauJ+sqorRVO+2l0zuwLLuNXhaVaAWXoomPFQRS2SFQf8ubE7Io4nWRNXqVQR7k52fG6dBH7kMnAzsPRn7g88t3FXHt86gAG/SXfzgKN/1ubVz14iyfVWL8AbbwIDAQAB',
            // 加密方式： **RSA2**
            'private_key' => 'MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDKv2VTYspqx5T02ySirITgUD9LYX9u29ditZdHoEnqC41Kk+DydsMO84QhOIJGUx4Am3AWTg7MJHb3BtonKJ8rAlVcOxHGFRhC8rxpGRPnAkvZZmpFLjCkOgnKf+qps5vw8yTteFjhon7lpGCrJtykY4s7+wvc0jiN3isWDGkFq3keqiZV7+nK4QW0JqHxJF0pVQboeu2+Ni8mo9S+Ej5CoijCiZgqqff0h25uaNEcNzbrnjv0a/L0JjSxo3m5ILT3+30wc5g8hZ3gVqW9NhLNmV+bh3YgYXJgcFwlLrBeTdsebBdGn1VpBSQvz2w5OnXxNXuIQSLG1qlD0QDFllyTAgMBAAECggEBALsMJMDvTWuBway8WGoz20rO/fXfdx+hdm48tdqAyHBCRBHfqBJI+t/aTbYQWi/jErTgsmIBlalEovR3v9+MnHujZXj3jgg/AekR5DzZxADFn5Br6fL1EC8S1GGb7bSuXVnIF/N1qhpQPd5C7mQ4MCsBIz0s+N66my5XH0zyGhn9WZNx2rqRQfAbLpx4QL/ZsEzQqRLGzXsbwH8Kq/lbsIroBo2C2ikMLXLuBvsuibMadAECkEaR73SJL3jmGz2v4b+mSSuaw8faKgBCFWFvH5binQbOtNqvTaOYBEt9SyLrLcd3rrgnfGiSSUKz5YtMNjGt5sQBX/UFZMIpYpjjwcECgYEA75rmMIMqYD2qqDKc6h6v8OpT5fw8nmF2ScAgbAU7z/qUlNi9XMUG8ov9pUiupfWOq9g4aJt0Kk4CNj7UPiPEFJ9aNMI09mOlBaUasjgRwqKLYo+1lqWK6zgnDzNOWDyp9hq2XNwA28DtEfFNbE8P6D36lIhtR9DLWRepY1+EhGMCgYEA2J7f1irsxsdkYvGrVNRIM54bG/rVomaxxd7H/PcHa1lVhnnvsqvJDKTXjIcC2MZKWPsIVP1iWuZpNl8jy33f/IHASAH4sCWxI89Mjww7VWsbUVLNAVaGp7r/hKrOGexzWAagDIqEgnJAL30omcAJzzXEETRyqrDr7mSTyJOXxhECgYEA1VCIYuRDk88S4g+9V0nexZM5AmXf6flHAD3GH6VBLNYf9axIWhEnMESlmsLsid/mFuO2xJqxfwBYQ8cH2hKpfNqpypKj6D+qKS5maAg295sSkLr0pZvX47XoQEYjF7dacToy5NURBpPp+7FihmyU8uRK9HXJJMikYTsJmOju55UCgYAdlEwyXXgpiI6fqCpiEf6t9bfz8SN84pMB1vLuCvlbYj54d2wQtL5mWJgKW2E7IpCCZ/zyRgtJKE9Tmlgz8ENGop0T+BjyTKNMpYDpw5zShCadyzWtKhiHDNTZU82C4rO5YGY4cC259knnciq6G+v6/HeCdev2fOQqkFdRuz2tUQKBgFmW1jHBTIMZ4QT0/mC5yww2dNrexYOuPPbPsk5BP3Pri5JKSpV5IIyIJf1H6l/6t+4bquv2DpkdFI+xPIm96hSiQR4TUxwUIUKeJXuLorzTWUNx51NzhazfVcolucWbo2PbRNO/mrrJoobI/PmYFcRHX+qRXvo1pyYo6cNnXgUf',
            'log' => [ // optional
                'file' => $_SERVER['DOCUMENT_ROOT'].'alipay.log',
                'level' => 'debug'
            ],
        ];
        $param =
            [
                'out_biz_no'=>$out_biz_no,
                'payee_type'=>'ALIPAY_LOGONID',
                'payee_account'=>15011154612,
                'amount'=>'0.1',
                'payer_show_name'=>'测试提现',
                'payee_real_name'=>'',
                'remark'=>'转账备注',
            ];

     *
     * 转账到用户支付宝
     * @param $config 配置文件，例子如上
     * @param $out_biz_no 提现订单编号
     * @param $payee_account 提现账号
     * @param $amount 提现金额
     * @param $payer_show_name 发送给客户信息
     * @param $payee_real_name 真实姓名
     * @param $remark 备注信息
     *
     * */
    public function transfer($config,$out_biz_no,$payee_account,$amount,$payer_show_name,$payee_real_name='',$remark='')
    {

        $param =
            [
                'out_biz_no'=>$out_biz_no,
                'payee_type'=>'ALIPAY_LOGONID',
                'payee_account'=>$payee_account,
                'amount'=>$amount,
                'payer_show_name'=>$payer_show_name,
                'payee_real_name'=>$payee_real_name,
                'remark'=>$remark,
            ];
        $alipay = Pay::alipay($config)->transfer($param);

        return $alipay;
    }
}